<script src="${rc.getContextPath()}/manage/js/dwzCustomJs/dwz.custom.advancedquery.js?v=${ver}" type="text/javascript"></script>
<#include "/common/pagerForm.html">
<form rel="pagerForm" method="post" action="" class="required-validate" onsubmit="return navTabSearch(this)">
<input type="hidden" id="advancedStatus" name="advancedStatus" value="${condition.advancedStatus!''}" />
<div class="pageHeader">
    <div class="searchBar">
        <ul class="searchContent">
            <li ><label><@label key='productionOrderNum.C,colon'>生产订单编号：</@label></label> <input type="text" name="productionOrderNum" value="${condition.productionOrderNum!''}"/></li>
           
           	<li ><label><@label key='requirementDate.C,colon'>需求日期：</@label></label>
            <input type="text" class="date"   name="minRequirementDate" readonly max_date="{maxRequirementDate}" value="${condition.minRequirementDate!''}"/><a class="inputDateButton" href="javascript:;">选择</a>
            <li ><label><@label key="to.C,colon">至：</@label></label>
            <input type="text" class="date"  name="maxRequirementDate" readonly min_date="{minRequirementDate}" value="${condition.maxRequirementDate!''}"/><a class="inputDateButton" href="javascript:;">选择</a></li>
                        
        </ul>
        <ul class="searchContent">
            <li ><label><@label key='materialCode.C,colon'>物料编号：</@label></label> <input type="text" name="materialCode" value="${condition.materialCode!''}"/></li>
            
            <li ><label><@label key='orderType.C,colon'>订单类型：</@label></label> 
                <select name="orderTypeCode">
                    <option value="" ><@label key='all.C'>所有</@label></option>
                    <#if orderTypes??>
                        <#list orderTypes as orderType>
                            <option value="${orderType.orderTypeCode!''}" <#if condition.orderTypeCode?? && condition.orderTypeCode == orderType.orderTypeCode> selected</#if> >${orderType.orderTypeText!''}</option>
                        </#list>
                    </#if>
                </select>
            </li>
             <li ><label><@label key='orderStatusECode.C,colon'>订单状态：</@label></label> 
                <select name="statuseCode">
                    <option value="" ><@label key='all.C'>所有</@label></option>
                    <#if orderStatusECode??>
                        <#list orderStatusECode as ecode>
                            <option value="${ecode.eCode!''}" <#if condition.statuseCode?? && condition.statuseCode == ecode.eCode> selected</#if> >${ecode.eCodeText!''}</option>
                        </#list>
                    </#if>
                </select>
            </li>
            <li class="query">
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit"><@label key="query.B">查询</@label></button>
                    </div>
                </div>
            </li>
            <li class="advancedQuery" >            
                <a id="advancedQuery"href="javascript:void(0);"   onclick="openAdvanced(navTab.getCurrentPanel())">
                    <@label key="advancedQuery.C">高级查询</@label>
                </a>
                <span  onclick="openAdvanced(navTab.getCurrentPanel());"></span>            
            </li>
        </ul>
    </div>
</div>
<div id="collapsablePanel" style="display:none;" class="pageHeader" >
    <div class="searchBar">
        <ul class="searchContent">
       	 	<li ><label><@label key='productOrderNum.C,colon'>产品订单编号：</@label></label><input type="text" name="productOrderNum" value="${condition.productOrderNum!''}"/></li>
            <li ><label><@label key='productionlotNum.C,colon'>生产批次号：</@label></label><input type="text" name="productionlotNum" value="${condition.productionlotNum!''}"/></li>
            <li><label><@label key="operationScheduleFlag.C,colon">工序派工：</@label></label> <select name="operationScheduleFlag">
                        <option value=""><@label key="all.C">所有</@label></option>
                        <option value="0"<#if condition.operationScheduleFlag?? && condition.operationScheduleFlag == 0> selected="selected"</#if>><@label key="no.C">否</@label></option>
                        <option value="1"<#if condition.operationScheduleFlag?? && condition.operationScheduleFlag == 1> selected="selected"</#if>><@label key="yes.C">是</@label></option>
                </select>
            </li>
            <li ><label><@label key='materialText.C,colon'>物料名称：</@label></label> <input type="text" name="materialText" value="${condition.materialText!''}"/></li>
            
        </ul>
        <ul class="searchContent">
        <li>
            <label>
                <@label key='createUser.C,colon'>创建人：</@label>
            </label>
            <input type="text" name="createUser" value="${condition.createUser!''}"/>
        </li>
         <li><label><@label key='createDateTime.C,colon'>创建日期从：</@label></label>
            <input type="text" class="date" readonly="readonly" size="17" max_Date="{maxCreateDateTime}"  name="minCreateDateTime" value="${condition.minCreateDateTime!''}"/>
            <a class="inputDateButton" href="javascript:;">选择</a>
            </li>
            <li><label><@label key="to.C,colon">至：</@label></label>
            <input type="text" class="date" readonly="readonly" size="17" min_Date="{minCreateDateTime}" name="maxCreateDateTime"  value="${condition.maxCreateDateTime!''}"/>
            <a class="inputDateButton" href="javascript:;">选择</a>
        </li>
        </ul>
        <ul class="searchContent">
            <li>
            <label>
                <@label key='modifyUser.C,colon'>修改人：</@label>
            </label>
            <input type="text" name="modifyUser" value="${condition.modifyUser!''}"/>
            </li>
            <li><label><@label key='modifyDateTime.C,colon'>修改日期从：</@label></label>
            <input type="text" class="date" readonly="readonly" size="17"  max_Date="{maxModifyDateTime}" name="minModifyDateTime" value="${condition.minModifyDateTime!''}"/>
            <a class="inputDateButton" href="javascript:;">选择</a>
            </li>
            <li><label><@label key="to.C,colon">至：</@label></label>
            <input type="text" class="date" readonly="readonly" size="17" min_Date="{minModifyDateTime}" name="maxModifyDateTime"  value="${condition.maxModifyDateTime!''}"/>
            <a class="inputDateButton" href="javascript:;">选择</a>
            </li>
        </ul>
        <ul class="searchContent">
            
            <li>
                <label><@label key='customer.C,colon'>客户：</@label></label> 
                <input type="text" name="customer" value="${condition.customer!''}"/>
            </li>
            <li>
                <label><@label key='customerOrder.C,colon'>客户订单：</@label></label> 
                <input type="text" name="customerOrder" value="${condition.customerOrder!''}"/>
            </li>
            <li>
                <label><@label key='priority.C,colon'>优先级：</@label></label> 
                <input type="text" name="priority" class="digits" value="${condition.priority!''}"/>
            </li>
        </ul>
    </div>
</div>    
</form>

<div class="pageContent">

    <div class="panelBar">
        <ul class="toolBar">
            <@buttonRight menuCode="productionOrder_add" labelKey="add.B" defalutName="新增">
            <li><a class="add" target="dialog" mask="true" width="650" height="600" rel="order_tab"  href="${rc.getContextPath()}/manage/productionOrder/addProductionOrder?navTabId=${navTabId!''}"><span><@label key="add.B">新增</@label></span></a></li></@buttonRight>
            <@buttonRight menuCode="productionOrder_edit" labelKey="edit.B" defalutName="编辑">
            <li><a class="edit" target="dialog" mask="true" width="650" height="600" rel="order_tab" preevent="productionOrderJs._checkEditButtonEnable"
            href="${rc.getContextPath()}/manage/productionOrder/editProductionOrder?productionOrderNum={production_id}&navTabId=${navTabId!''}"><span><@label key="edit.B">编辑</@label></span></a></li></@buttonRight>
            <@buttonRight menuCode="productionOrder_view" labelKey="view.B" defalutName="详情">
            <li><a class="icon" target="dialog" mask="true" width="950" height="600" rel="order_tab"
            href="${rc.getContextPath()}/manage/productionOrder/viewProductionOrder?productionOrderNum={production_id}&navTabId=${navTabId!''}"><span><@label key="view.B">详情</@label></span></a></li></@buttonRight>
            <@buttonRight menuCode="productionOrder_delete" labelKey="delete.B" defalutName="删除">
            <li><a class="delete" target="ajaxTodo" title="<@label key='delete_sure.D'>确定要删除</@label>？"
            href="${rc.getContextPath()}/manage/productionOrder/deleteProductionOrder?productionOrderNum={production_id}&navTabId=${navTabId!''}"><span><@label key="delete.B">删除</@label></span></a></li></@buttonRight>
            <@buttonRight menuCode="productionOrder_issued" labelKey="issued.B" defalutName="下达">
            <li><a class="rel" target="dialog" mask="true" width="800" height="600" rel="order_tab" preevent="productionOrderJs._checkIssuedButtonEnable" title="<@label key='placeOrder.C'>下达</@label>"
            href="${rc.getContextPath()}/manage/productionOrder/decomposeProductionOrder?productionOrderNum={production_id}&navTabId=${navTabId!''}"><span><@label key="issued.B">下达</@label></span></a></li></@buttonRight>
            <@buttonRight menuCode="productionOrder_back" labelKey="backissued.B" defalutName="撤回下达">
            <li><a class="unRel" target="ajaxTodo"
            href="${rc.getContextPath()}/manage/productionOrder/backissuedProductionOrder?productionOrderNum={production_id}&navTabId=${navTabId!''}"><span><@label key="backissued.B">撤回下达</@label></span></a></li></@buttonRight>
            <@buttonRight menuCode="productOrder_close" labelKey="forceClose.B" defalutName="强制关闭">
            <li><a class="delete" target="ajaxTodo" mask="true" title="<@label key='ok.B,forceClose.B'>确定强制关闭吗？</@label>" 
            href="${rc.getContextPath()}/manage/productionOrder/closeProductionOrder?productionOrderNum={production_id}&navTabId=${navTabId!''}"><span><@label key="forceClose.B">强制关闭</@label></span></a></li></@buttonRight>
        </ul>
    </div>
    <table class="table" width="2200" layoutH="160">
        <thead>
            <tr>
                <th width="40"><@label key="serialNumber.C">序号</@label></th>
                <th width="120" orderField="productionOrderNum" <#if (page.orderField?? && page.orderField == 'productionOrderNum')>class="${page.orderDirection!''}"</#if>><@label key='productionOrderNum.C'>生产订单编号</@label></th>
                <th width="120"><@label key='productOrderNum.C'>产品订单编号</@label></th>
                <th width="80"><@label key="operationScheduleFlag.C">工序派工</@label></th>                
                <th width="80"><@label key='orderType.C'>订单类型</@label></th>
                <th width="80"><@label key='orderStatusECode.C'>订单状态</@label></th>
                <th width="100"><@label key='materialCode.C'>物料编号</@label></th>
                <th width="100"><@label key='materialText.C'>物料名称</@label></th>
                <th width="80"><@label key='plannedQuantity.C'>计划数量</@label></th>
                <th width="80"><@label key='releasedQuantity.C'>已下达数量</@label></th>
                <th width="100"><@label key='requirementDate.C'>需求日期</@label></th>
                <th width="80"><@label key='productionlotNum.C'>生产批次号</@label></th>
                <th width="140"><@label key='plannedstartDateTime.C'>计划开始时间</@label></th>
                <th width="140"><@label key='plannedendDateTime.C'>计划结束时间</@label></th>
                <th width="100"><@label key='cmprocess_code.C'>工艺编号</@label></th>
                <th width="50"><@label key='cmprocessrev.C'>工艺版本</@label></th>
                <th width="80"><@label key='completedQuantity.C'>完工数量</@label></th>
                <th width="80"><@label key='scrappedQuantity.C'>报废数量</@label></th>
                <th width="80"><@label key='repairQuantity.C'>返修数量</@label></th>
                <th width="140"><@label key='actualstartDateTime.C'>实际开始时间</@label></th>
                <th width="140"><@label key='actualendDateTime.C'>实际结束时间</@label></th>
                <th width="80"><@label key='createUser.C'>创建人</@label></th>
                <th width="140" orderField="createDateTime" <#if (page.orderField?? && page.orderField == 'createDateTime')>class="${page.orderDirection!''}"</#if>><@label key='createDateTime.C'>创建时间</@label></th>
                <th width="80"><@label key='modifyUser.C'>修改人</@label></th>
                <th width="140" orderField="modifyDateTime" <#if (page.orderField?? && page.orderField == 'modifyDateTime')>class="${page.orderDirection!''}"</#if>><@label key='modifyDateTime.C'>修改时间</@label></th>
            </tr>
        </thead>
        <tbody>
        <#if page??><#if (page.data?size>0)> <#list page.data as production>
            <tr target="production_id" rel="${production.productionOrderNum!''}">
                <td>${page.startRow + production_index}</td>
                <td>${production.productionOrderNum!''}</td>
                <td>${production.productOrderNum!''}</td>
                <td><#if production.operationScheduleFlag == 0><@label key="no.C">否</@label><#else><@label key="yes.C">是</@label></#if></td>                
                <td>${production.orderTypeText!''}</td>
                <td><#if orderStatusECode??>
                    <#list orderStatusECode as ecode>
                        <#if production.statuseCode == ecode.eCode>${ecode.eCodeText!''}<#break></#if>
                    </#list>
                </#if>
                </td>
                <td>${production.materialCode!''}</td>
                <td>${production.materialText!''}</td>
                <td>${production.plannedQuantity!''}</td>
                <td>${production.releasedQuantity!''}</td>
                <td>${(production.requirementDate?string("yyyy-MM-dd"))?if_exists}</td>
                <td>${production.productionlotNum!''}</td>
                <td>${(production.plannedstartDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${(production.plannedendDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${production.processCode!''}</td>
                <td>${production.processRev!''}</td>
                <td>${production.completedQuantity!''}</td>
                <td>${production.scrappedQuantity!''}</td>
                <td>${production.repairQuantity!''}</td>
                <td>${(production.actualstartDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${(production.actualendDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${production.createUser!''}</td>
                <td>${(production.createDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${production.modifyUser!''}</td>
                <td>${(production.modifyDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
            </tr>
        </#list>
        <#else>
        <tr target="production_id">
            <td colspan="20" class="noData">======<@label key='noListData.C'>列表无数据</@label>=====</font></td>
        </tr>
        </#if>
        <#else>
        <tr target="production_id">
                <td colspan="20" class="noData">======<@label key='noListData.C'>列表无数据</@label>=====</font></td>
        </tr>
        </#if>
        </tbody>
    </table>
    <#include "/common/panelBar.html">
</div>
<script type="text/javascript">
    $(function() {
        initAdvancedQuery(navTab.getCurrentPanel());
        
    });
    var productionOrderJs = {
            editEnable : true,
            issuedEnable : true,
            _checkEditButtonEnable : function() {
                var id = $("#production_id",navTab.getCurrentPanel()).val();
                productionOrderJs.editEnable = true;
                if(id && id!=""){
                    $.ajax({
                        async : false,
                        dataType : "json",
                        url:hostUrl +"/productionOrder/checkedButtonEnable",
                        data:{'productionOrderNum':id,'type':'edit'},
                        success:function(data){
                            if(data.statusCode == DWZ.statusCode.error){
                                productionOrderJs.editEnable = false;
                                alertMsg.error(data.message);
                            }
                        }
                    });
                }
                return productionOrderJs.editEnable;
            },
            _checkIssuedButtonEnable : function() {
                var id = $("#production_id", navTab.getCurrentPanel()).val();
                productionOrderJs.issuedEnable = true;
                if(id && id!=""){
                    $.ajax({
                        async : false,
                        dataType : "json",
                        url:hostUrl +"/productionOrder/checkedButtonEnable",
                        data:{'productionOrderNum':id,'type':'issued'},
                        success:function(data){
                            if(data.statusCode == DWZ.statusCode.error){
                                productionOrderJs.issuedEnable = false;
                                alertMsg.error(data.message);
                            }
                        }
                    });
                }
                return productionOrderJs.issuedEnable;
            }
    }
</script>
<!-- 下达动作触发 分解，还是可以直接先分解，那么分解的动作只是针对未下达的生产订单，如果对于已经下达的生产订单下面要显示什么呢？ 还有详情页面是否要显示下达的详细信息还是也在本页面显示 -->